package com.miracle.common.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * com.miracle.common.util
 * (c)2018 AIR Times Inc. All rights reserved.
 *
 *
 * @author WangJQ
 * @version 1.0
 * @date 2018/7/14 8:47
 * @see com.miracle.common.util
 */
public class TimeUtil {
    public static class Pattern {
        public static final String DATE = "yyyy-MM-dd";
        public static final String TIME = "yyyy-MM-dd HH:mm:ss";
    }

    /**
     * 时间戳转日期
     * @param milSecond 时间戳
     * @param pattern 格式
     * @return
     */
    public static String getDateToString(String milSecond, String pattern) {
        try {
            long milles = Long.parseLong(milSecond);
            Date date = new Date(milles);
            SimpleDateFormat format = new SimpleDateFormat(pattern);
            return format.format(date);
        } catch (NumberFormatException e) {
            return "";
        }
    }
}
